/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package dataandvariable;

import java.util.ArrayList;

/**
 *
 * @author sochy
 */
public class MyOwnDataType {
    public static void main(String[] args) {
        
        MyType mytype1 = new MyType();
        
        ArrayList a = new ArrayList();
        a.add(0, 1);
        a.add(1, "T2");
        a.add(2, "T3");
        
        for(Object o : a){
            System.out.println(o);
        }
        

        
        ArrayList<MyType> l = new ArrayList<>();
        
        
        mytype1.setI(222);
        mytype1.setS("Vey");
        l.add(mytype1); // add object mytype1 to arraylist
        
        MyType mytype2 = new MyType();
        mytype2.setI(2);
        mytype2.setS("Lymeng");
        l.add(mytype2); // add object mytype2 to arraylist
        
        for(MyType m : l){
            System.out.println("ID:"+m.getI());
            System.out.println("Name:"+m.getS());
            System.out.println("");
        }
        
    }
}


class MyType{
    private int i =0;
    private String s=null;

    public int getI() {
        return i;
    }

    public void setI(int i) {
        this.i = i;
    }

    public String getS() {
        return s;
    }

    public void setS(String s) {
        this.s = s;
    }

    
}
